package com.bitbank.smartdevice.vo

import android.arch.persistence.room.Entity
import android.arch.persistence.room.PrimaryKey
import android.os.Parcel
import android.os.Parcelable


/**
 *  Date：2018/11/23
 *  Author：xulee
 *  Desc：
 */
@Entity
data class Image (
    @PrimaryKey(autoGenerate = true)
    var id: Long,
    var imageUrl: String,
    var imageId: String
) : Parcelable {

    constructor(source: Parcel) : this(
        source.readLong(),
        source.readString(),
        source.readString()
    )

    override fun describeContents() = 0

    override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
        writeLong(id)
        writeString(imageUrl)
        writeString(imageId)
    }

    companion object {
        @JvmField
        val CREATOR: Parcelable.Creator<Image> = object : Parcelable.Creator<Image> {
            override fun createFromParcel(source: Parcel): Image =
                Image(source)
            override fun newArray(size: Int): Array<Image?> = arrayOfNulls(size)
        }
    }
}